Managing Code Formatting
The Code Editor gives you the ability to format your code with options such as indenting, hiding text, displaying URLs, and so forth. The language engine also provides features to auto-format your code as you type through Smart Indenting.
Indenting
You can choose three different styles of text indenting. You can also specify how many spaces compose a single indentation or tab, and whether the Editor uses tabs or space characters when indenting.
To choose an indention style
- On the Tools menu, click Options.
- Click Text Editor.
- Select the folder for your language, for example, HTML, or select All Languages to affect indenting settings for all languages.
- Click Tabs.
- Select one of the options under Indenting and click OK:
- None The cursor goes to the beginning of the next line.
- Block The cursor aligns the next line with the previous line.
- Smart (Default) The language service determines the appropriate indention style to use. For example, if you creating a For�Next loop in Visual Basic, the lines are indented accordingly.
To change indent tab settings
- On the Tools menu, click Options.
- Click Text Editor.
- Select the folder for your language, for example, HTML, or select All Languages to affect indenting settings for all languages.
- Click Tabs.
- To specify that tab characters are used in tab and indent operations, select Keep Tabs. To specify that space characters are used, select Insert Spaces.
If you selected Insert Spaces, you can enter the number of space characters each tab or indent represents under Tab Size or Indent Size respectively.
To indent code
- Select the text you want to indent.
- Click the TAB key, or click Indent .
To unindent code
- Select the text you want to unindent.
- Press SHIFT+TAB key, or click Unindent .
To automatically indent all of your code
- In Tools, Options, select Text Editor, All Languages, Tabs, and then select Smart from the Indenting group box.
- To select this option on a per-language basis, select Smart in the appropriate folder, starting by selecting Options from the Tools menu.
To automatically indent selected code
- Select the text you want to automatically indent.
- Click Format Selection in Edit, Advanced, or press CTRL+K, CTRL+F.
Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.
You can specify size of the tabs and the indents and whether or not the tab characters are converted to spaces.
To convert white space to tabs and vice versa
- Select the text whose white space (that is, the spaces between the characters) you want to convert from spaces to tabs.
- In Edit, Advanced, click Tabify Selection.
- To convert tabs to spaces, in Edit, Advanced, click Untabify Selection.
The functionality of these commands depends on the tab settings in Tools, Options, Text Editor, Tabs. For example, if the tab setting is four, Tabify Selection creates a tab for every four contiguous spaces, and Untabify Selection creates four spaces for every tab.
Hiding Text
By default, all text is displayed in the Code Editor, but in some circumstances you can hide the code from view. There are two different types of hidden text:
- Concealed (HTML Designer HTML view only) – Hidden text that is concealed has no indication that it is missing from the view. The only way to tell is to turn on line numbering. The HTML view of HTML Designer uses concealed text to provide you with a Script-only view where all text that is not part of the script code is hidden from view. If you select across concealed text and delete it, the non-visible concealed text is not deleted.
Note In the HTML Designer's HTML view, you can activate a "Script-Only" view in which only script blocks are displayed.
- Collapsed – You can choose to hide selected text from view by creating an outlining section. To do this, select the text, right-click, and click Hide Selection. The text then collapses under the top-most selected line, and a plus-sign (+) symbol displays in the indicator margin to the left of the line. To expand the lines for viewing, click the plus sign. The same procedure applies to outlining. If you select across collapsed text and delete it, all selected text is deleted, including the collapsed text.
The Hide Selection command works only with Stream selection and zero-width Box selection modes. The command is disabled for non-zero-width box selections.
In some languages you can also collapse code to definitions. Some languages, in addition to supporting Collapse To Definitions, have a mode where outlining is always on. As you type new definitions, the editor creates collapsible sections around the definition bodies of the new code. You can stop this with the Stop Outlining command.
Note A regular Find operation searches for text in hidden regions based on an option in the Find dialog box, but an incremental search does not.
Converting Text to Upper and Lower Case
You can use commands to convert text to all upper or lower case.
To switch text to upper or lower case
- Select the text you want to convert.
- To convert text to upper case, click CTRL+SHIFT+U, or click Make Uppercase in Edit, Advanced.
- To convert text to lower case, click CTRL+U, or click Make Lowercase in Edit, Advanced.
The case conversion commands do not affect the case of intrinsic commands.
Displaying and Linking to URLs
You can create and display active URLs (Uniform Resource Locators) in your code. You can then click the link and be taken to the web page in a browser. By default, the URLs:
- Appear underlined.
- Change the mouse pointer to a hand when you move over them.
- Open the URL site when single-clicked, if the URL is valid.
To display a clickable URL
- On the Tools menu, click Options.
- Click Text Editor.
- To change the option for only one language, click that language and then click General. To change the option for all languages, click All Languages and then click General.
- Under Display, select Enable single-click URL navigation.
Note If you turn this option off, you can still open a valid internet site by choosing the Open URL command from the Code Editor's context menu.